import React, { FC, useContext, useEffect } from 'react';
import { View, Text } from '@tarojs/components';
import { styled } from 'linaria/react';
import { useClassName } from '@/utils/index';
import { Button, Form } from 'antd-mobile';
import { useApplySettledInContext, ApplySettledInContext } from './ApplySettledInContext';
import BaseInfo from './BaseInfo/BaseInfo';
import SocialPlatform from './SocialPlatform/SocialPlatform';
import EnactiveAttainment from './EnactiveAttainment/EnactiveAttainment';
import AgencyOrAgent from './AgencyOrAgent/AgencyOrAgent';
import { apiGetArtistsSettledIn } from '@/pages/_server/_api/ApiArtistsSettledIn/apiGetArtistsSettledIn';
import Taro from '@tarojs/taro';

export interface IProps extends ICompProps {}
ApplySettledIn.defaultProps = {} as Partial<IProps>;
function ApplySettledIn(props: IProps) {
    const { className, style } = props;
    const localClassName = useClassName('ApplySettledIn', className);
    const { formRules } = useApplySettledInContext();
    const onFinish =async (val) => {
        console.log('点了提交',val);
        const res =await apiGetArtistsSettledIn(val)
        if(!res) return
        Taro.navigateTo({
            url: 'pages/Mine/Mine',
        });
    };
    return (
        <ApplySettledInContext.Provider value={{ formRules }}>
            <RootView className={localClassName} style={style}>
                <Form
                    className="form"
                    onFinish={onFinish}
                    footer={
                        <Button block type="submit" className="submitBtn" shape="rounded">
                            提交
                        </Button>
                    }>
                    <BaseInfo></BaseInfo>
                    <SocialPlatform></SocialPlatform>
                    <EnactiveAttainment></EnactiveAttainment>
                    <AgencyOrAgent></AgencyOrAgent>
                </Form>
            </RootView>
        </ApplySettledInContext.Provider>
    );
}
export default React.memo(ApplySettledIn as FC<IProps>);
const RootView = styled(View)`
    &.ApplySettledIn {
        padding: 20px;
        .form {
            --border-inner: 0;
            --border-top: 0;
            --border-bottom: 0;
        }
        .submitBtn {
            margin: auto;
            width: 520px;
            height: 90px;
            background: #ff8828;
            color: #fff;
            letter-spacing: 4px;
        }
    }
`;
